import mongoose from "../mongo";

const userSchema = new mongoose.Schema({
    userId:{ type: Number, required: true, unique: true },
    userName: { type: String, required: true, unique: true },
    // 1:管理员 2：应用管理员 3：普通用户
    role: { type: Number,required:true,},
    password: { type: String, required: true},
    email: { type: String},
    phone: { type: Number},
    appids: {type: Array},
    createTime: { type: Date },
    updateTime: { type: Date },
});

userSchema.pre('save', function (next) {
    this.createTime = new Date();
    next();
});

const userModel = mongoose.model('user', userSchema);
export default userModel;
